﻿@namespace Masa.Tsc.Web.Admin.Rcl.Components
@inherits TscComponentBase

<MTooltip Top>
    <ActivatorContent>
        <MCard @attributes="context.Attrs" Class="pa-6" OnClick="OnClickHandler" Style="@Style">
            <MCardText Class="d-flex justify-space-between pa-0 pb-4">
                <div class="d-flex flex-column justify-space-around">
                    <div>
                        <span class="masa h5">@Value.ServiceTotal</span>
                        @if (Value.IsShowApp)
                        {
                            <span class="masa h8 ml-1">/ @Value.AppTotal</span>
                        }
                    </div>
                    <span class="masa h8 regular3--text">@I18n.Team(Value.Text)</span>
                </div>
                <img src="_content/Masa.Tsc.Web.Admin.Rcl/img/team/@(Value.Icon+".svg")" />
            </MCardText>
            <MCardActions Class="pa-0">
                <MProgressLinear Height="4" Color="@Value.Color" Rounded Value="100"></MProgressLinear>
            </MCardActions>
        </MCard>
    </ActivatorContent>
    <ChildContent>
        <div>@I18n.Team("Project Count")：@Value.ServiceTotal</div>
        @if (Value.Value is MonitorStatuses.Error or MonitorStatuses.Warn)
        {
            <div>@I18n.Team("Log Count")：@Value.AppTotal</div>
        }
	else
	{
            <div>@I18n.Team("Service Count")：@Value.AppTotal</div>
	}
    </ChildContent>
</MTooltip>

@code {
    [Parameter]
    public AppMonitorViewDto Value { get; set; } = default!;

    [Parameter]
    public EventCallback<AppMonitorViewDto> OnClick { get; set; }

    private async Task OnClickHandler()
    {
        if (OnClick.HasDelegate)
        {
            await OnClick.InvokeAsync(Value);
        }
    }
}
